//
// Created by Administrator on 2021/5/21.
//
#include "iostream"

using namespace std;

int main(){
    
    //1.create array
    int arr[5] = {1, 2, 3, 4, 5};
    
    cout << "数组逆置前：" << endl;
    for (int i = 0; i < 5; i++) {
        cout << arr[i] << endl;
    }

    //2.实现逆置
    /*
     * 记录起始下标位置
     * 记录结束下标位置
     * 起始下标与结束下标的元素互换
     * 起始位置++ 结束位置--
     * 循环执行第一个，直到起始位置>=技术位置
     */
    int start = 0;
    int end = sizeof(arr) / sizeof(arr[0]) - 1;

    while (start < end){
        int temp = arr[start];
        arr[start] = arr[end];
        arr[end] = temp;

        start ++;
        end --;
    }

    //3.打印逆置
    cout << "converse array is: " << endl;
    for (int i = 0; i < 5; i++) {

        cout << arr[i] << endl;
    }
    
    system("pause");
    
    return 0;
}